/*
 *
s5 = aaa
s5 = aaabbb
false
s5 length = 6
aaabbb
s2= bbb   s3= aaa

 */

#include <iostream>
#include <cstdio>
using namespace std;
int main(){
 
	/*定义*/
	string s1;  //定义空字符串
	string s2("aaa"); 
	string s3 = string("bbb");
	string s4 = "cccc";

	/*字符串的拷贝*/
	string s5 = s2;  // char *p5 = p2; 
	cout << "s5 = " << s5 << endl;

	/*拼接*/
	s5 += s3;
	cout << "s5 = " << s5 << endl;

	/*字符串比较*/
	if(s2 == s3){    
		//strcmp(.....)
		cout << "true" << endl;
	}else{
		cout << "false" << endl;
	}

	/*取字符串长度*/
	cout << "s5 length = "<< s5.length() << endl;

	/*转换为C风格字符串*/
	const char *p = s5.c_str();
	printf("%s\n", p);

	/*交换*/
	swap(s2, s3);
	cout << "s2= "<< s2 << "   s3= "<< s3<< endl;
	return 0;
}
